//
//  NSString+Size.m
//  OAProject
//
//  Created by yhj on 2017/3/15.
//  Copyright © 2017年 cdnunion. All rights reserved.
//

#import "NSString+Size.h"

@implementation NSString (Size)

-(CGSize)newSizeWithFont:(UIFont *)font
{
    return [self newSizeWithFont:font constrainedToSize:CGSizeMake(320, 999)];
}
-(CGSize)newSizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size
{
    if(!IOS7)
    {
        return [self sizeWithFont:font constrainedToSize:size];
    }
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
    paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping;
    NSDictionary *attributes = @{NSFontAttributeName:font,
                                 NSParagraphStyleAttributeName:paragraphStyle.copy};
    return [self boundingRectWithSize:size
                              options:NSStringDrawingUsesLineFragmentOrigin
                           attributes:attributes
                              context:nil].size;
}


@end
